CNAME record

A CNAME record or Canonical Name record is a type of resource record in the Domain Name System (DNS) that specifies that the domain name is an alias of another, canonical domain name. This helps when running multiple services (like an FTP server and a webserver; each running on different ports) from a single IP address. Each service can then have its own entry in DNS (like ftp.example.com. and www.example.com.). Network administrators also use CNAMEs when running multiple HTTP servers on the same port, with different names, on the same physical host.

Contents

Details

CNAME records are specified in RFC 1034. CNAME records are handled specially in the domain name system, and have several restrictions on their use. When a DNS resolver encounters a CNAME record while looking for a regular resource record, it will restart the query using the canonical name instead of the original name. (If the resolver is specifically told to look for CNAME records, the CNAME alias is returned, rather than restarting the query.) The canonical name that a CNAME record points to can be anywhere in the DNS, whether local or on a remote server in a different DNS zone.

For example, if there is a DNS zone as follows:

foo.example.com.        CNAME  bar.example.com.
bar.example.com.        A      192.0.2.23

When an A record lookup for foo.example.com is done, the resolver will see a CNAME record and restart the checking at bar.example.com and will then return 192.0.2.23.

Which is the "CNAME"?

RFC 2181, "Clarifications to the DNS Specification", includes a warning on the use of the word "CNAME". "The CNAME" or "a CNAME" is often used to refer to the label, or left-hand part, of a CNAME record. However, as "CNAME" is an abbreviation of "canonical name", this usage is inaccurate; the label is an alias for the right-hand side (the RDATA portion), which is (or should be) a canonical name.[1] In other words, a CNAME record like this:

foo.example.com.        CNAME  bar.example.com.

may be read as:

foo.example.com is an alias for the canonical name (CNAME) bar.example.com.

The canonical name itself must be defined by a record other than a CNAME or DNAME record.

Restrictions

foo.example.com.  CNAME  bar.example.com.
bar.example.com.  CNAME  foo.example.com.
example.com.      MX     0   foo.example.com.
foo.example.com.  CNAME  host.example.com.
host.example.com. A      192.0.2.1

DNAME record

A DNAME record or Delegation Name record is defined by RFC 2672. A DNAME record creates an alias for one or more subdomains of a domain. In contrast, the CNAME record creates an alias only of a single name (and not its subdomains). Like the CNAME record, the DNS lookup will continue by retrying the lookup with the new name. If a DNS resolver sends a query without EDNS, or with EDNS version 0, then a name server synthesizes a CNAME record to simulate the semantics of the DNAME record.

For example, if there is a DNS zone as follows:

foo.example.com.        DNAME  bar.example.com.
bar.example.com.        A      192.0.2.23
xyzzy.bar.example.com.  A      192.0.2.24
*.bar.example.com       A      192.0.2.25

An A record lookup for foo.example.com will fail because a DNAME is not a CNAME.

However, a look up for xyzzy.foo.example.com will be DNAME mapped and return the A record for xyzzy.bar.example.com which is 192.0.2.24; if the DNAME record had been a CNAME record, this request would have failed.

Lastly, a request for baz.foo.example.com would be DNAME mapped and return 192.0.2.25.

See also

References

  1. ^ "RFC 2181: Clarifications to the DNS Specification". IETF. July 1997. http://tools.ietf.org/html/rfc2181#section-10.1.1. Retrieved 2011-03-09. 
  2. ^ a b Mockapetris, P. (November 1987). "RFC1034 - Domain Names, Concepts and Facilities" (in En-US). ISI. http://www.faqs.org/rfcs/rfc1034.html. Retrieved 16 April 2011. 
  3. ^ Barr, D. (February 1996). "Common DNS Operational and Configuration Errors" (in En-US). RFC1912. The Pennsylvania State University. http://www.faqs.org/rfcs/rfc1912.html. Retrieved 16 April 2011. 
  4. ^ Braden, R. (October 1989). "RFC1123 - MAIL - SMTP & RFC-822" (in En-US). http://www.ietf.org/rfc/rfc1123.txt. Retrieved 3 June 2011. 
  5. ^ Bernstein, D.J.. "CNAME records in mail" (in En-US). http://cr.yp.to/im/cname.html. Retrieved 3 June 2011. 

External links